<?php

namespace application\Controller;

use application\Components\BaseController;
use application\Module\Help;
use library\Core\Db\CDbCriteria;
use application\Model\HelpModel;
use application\Comm\Func;
use library\Core\Config;
use application\Comm\Request;

class HelpController extends BaseController
{
    /**
     * @param $id
     * 详情
     */
    public function actionView($id)
    {
    	$name = Request::getParam('name');
        $help = new Help();
        $help_category_id = Config::getParamsVal('HELP_CATEGORY');
//         $help_category_id = [
//             1 => '关于美乐乐',
//             2 => '新手指南',
//            3 => '安装配送',
//            4 => '售后服务',
//            5 => '购物保障',
//            6 => '量尺设计',
//         ];
        $help_list = [];
        foreach ($help_category_id as $k => $v) {
            $help_list[$k] = $help->getList($k);
        }
        $criteria = new CDbCriteria();
        $select = [
            'id',
            'name',
            'description',
            'url',
            'category_id',
            'content',
            'status',
            'create_time',
            'update_time',
            'orderby',
        ];
        $criteria->select($select);
        $criteria->addEqCondition('id', $id);
        $helpModel = new HelpModel();
        $data = $helpModel->getRow($criteria);
        $this->render('help/view', [
        	'name' => $name,
        	'id'  =>$id,
            'data' => $data,
            'help_list' => $help_list,
            'help_category_id' => $help_category_id,

        ]);
    }

}
